using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Web.Security;
using WCSFContrib.ECommerceCatalog.BusinessEntities.Enums;

namespace WCSFContrib.ECommerceCatalog.BusinessEntities
{
    public class Order
    {
        private Int32 orderId;

        public Int32 OrderId
        {
            get { return orderId; }
            set { orderId = value; }
        }
    
        private string user;

        public string User
        {
            get { return user; }
            set { user = value; }
        }
	
        private DateTime orderDate;

        public DateTime OrderDate
        {
            get { return orderDate; }
            set { orderDate = value; }
        }

        private Address billingAddress;

        public Address BillingAddress
        {
            get { return billingAddress; }
            set { billingAddress = value; }
        }

        private Address shippingAddress;

        public Address ShippingAddress
        {
            get { return shippingAddress; }
            set { shippingAddress = value; }
        }

        private OrderStatus orderStatus;

        public OrderStatus OrderStatus
        {
            get { return orderStatus; }
            set { orderStatus = value; }
        }

        private Payment paymentMethod;

        public Payment PaymentMethod
        {
            get { return paymentMethod; }
            set { paymentMethod = value; }
        }

        private Collection<OrderItem> orderItems = new Collection<OrderItem>();

        public Collection<OrderItem> OrderItems
        {
            get { return orderItems; }
        }

        public double Total
        {
            get
            {
                double total = 0.0;
                
                foreach (OrderItem orderItem in this.orderItems)
                {
                    total += orderItem.Quantity * orderItem.Item.Price;
                }

                return total;
            }
        }

        public Order()
        {
        }

        public Order(Int32 orderId, string user, DateTime orderDate, Address billingAddress, Address shippingAddress, OrderStatus orderStatus, Payment paymentMethod, Collection<OrderItem> orderItems)
        {
            this.orderId = orderId;
            this.user = user;
            this.orderDate = orderDate;
            this.billingAddress = billingAddress;
            this.shippingAddress = shippingAddress;
            this.orderStatus = orderStatus;
            this.paymentMethod = paymentMethod;
            this.orderItems = orderItems;
        }
    }
}
